package com.sooncode.project.focusservice.controller;

import com.sooncode.project.core.finder.Page;
import com.sooncode.project.focusservice._.base.Utils;
import com.sooncode.project.focusservice.model.CourseHour;
import com.sooncode.project.focusservice.service.CourseHourService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("courseHour")
public class CourseHourController {
    @Autowired
    CourseHourService service;

    @PostMapping("courseHour")
    public boolean add(@RequestParam Map map){
        return service.add(map);
    }
    @PutMapping("courseHour")
    public boolean modify(@RequestParam String id,@RequestParam Map map){
        return service.modify(id,map);
    }
    @DeleteMapping("courseHour")
    public boolean delete(@RequestParam String[] ids){
        for(String id:ids){
            service.delete(id);
        }
        return true;
    }
    @GetMapping("courseHours")
    public Page<CourseHour> getPageList(@RequestParam String memberId,@RequestParam int pageSize,@RequestParam int pageIndex,@RequestParam Map map) {
        map.remove("pageSize");
        map.remove("pageIndex");
        map.remove("memberId");
        Utils.mapValueTrim(map);
        return service.getPage(memberId,pageSize,pageIndex-1,map);
    }

}
